package completion_failure;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.processing.Processor;
import javax.tools.JavaCompiler;
import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;

public class Main
{
	public static void main(String[] args)
  {
		List<String> options = new ArrayList<>();
		
		options.add("-proc:only");

		List<String> annotationProcessors = new ArrayList<>();
		annotationProcessors.add(AnnotationProcessor.class.getName());
		
		JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
		
		StandardJavaFileManager fileManager =
				compiler.getStandardFileManager(null, null, null);

		List<JavaFileObject> compilationUnits = new ArrayList<>();
		File file = new File("src/test/java/completion_failure/AnnotatedType.java");
		List<File> files = new ArrayList<>();
		files.add(file);
		compilationUnits.add(
				fileManager.getJavaFileObjectsFromFiles(files).iterator().next());
		
		CompilationTask compilationTask =
				compiler.getTask(
						null,
						fileManager,
						null,
						options,
						null,
						compilationUnits);

		List<Processor> processors = new ArrayList<>();
		processors.add(new AnnotationProcessor());

		compilationTask.setProcessors(processors);

		compilationTask.call();
	}
}